EditProperty = function(){
	return {
		
		savePropertyInfo : function() {
			if(!$('#propertyForm').form('validate')) {
				return;
			}
			var industryId = $('#industryId').val();
			var propertyId = $("#resourcePropertyId").val();
			var propertyFlag = $("#resourcePropertyFlag").val();
			var propertyName = $.trim($("#resourcePropertyName").val());
			var propertyCode = $.trim($("#resourcePropertyEnname").val());
			if(null == propertyFlag || "" == propertyFlag) {
				Ict.warn("请选择是否必填!");
				return;
			}
			$.post('/pc/property/checkName.htm', {'industryId' : industryId, 'propertyName' : propertyName, 'propertyId' : propertyId}, function(data) {
				if(data.code == '0') {
					Ict.warn("属性名称已存在,请重新输入!");
				} else {
					$.post('/pc/property/checkCode.htm', {'industryId' : industryId, 'propertyCode' : propertyCode, 'propertyId' : propertyId}, function(result) {
						if(result.code == '0') {
							Ict.warn("属性代码已存在,请重新输入!");
						} else {
							EditProperty.commitForm();
						}
					});
				}
			});
		},
		
		commitForm : function() {
			$("input[name='resourcePropertyName']").attr("disabled", false);
			$("input[name='resourcePropertyEnname']").attr("disabled", false);
			$('#propertyForm').form('submit', {
				url      : "/pc/property/editProperty.htm",
				onSubmit : function() {
					return $('#propertyForm').form('validate');
				},
				success  : function(data) {
					if(data == "SUCCESS") {
						Ict.info("保存成功!", function() {
			    			Ict.closeWin();
			    			$("#propertyDataGrid").datagrid("reload");
			    		});
					} else {
						Ict.info("保存失败");
					}
				}
			});
		}
	};
}();

$(function(){
	$("input[name='resourcePropertyName']").attr("disabled", true);
	$("input[name='resourcePropertyEnname']").attr("disabled", true);
});